﻿package org.xhs.report.common.utils
{
    import baidu.ui.managers.*;
    import baidu.wenku.common.*;
    import baidu.wenku.common.model.*;
    import flash.events.*;
    import flash.net.*;

    public class WenkuLog extends EventDispatcher
    {
        public static const LOGURL_DRAGPAGES:String = "http://wenku.baidu.com/tongji/view.html?type=dragdrop&num=";
        public static const LOGURL_LOADTIME:String = "http://wenku.baidu.com/tongji/view.html?type=contentload&success=1&time=";
        public static const LOGURL_LOADDOCFAIL:String = "http://wenku.baidu.com/tongji/view.html?type=contentload&success=0";
        public static const LOGURL_STAYINPAGE:String = "http://wenku.baidu.com/tongji/view.html?type=read";
        public static const LOGURL_BROWSER:String = "http://wenku.baidu.com/tongji/view.html?type=browse";
        public static const LOGURL_LOADDATA:String = "http://wenku.baidu.com/tongji/api.html?type=flash&subtype=play";
        public static const LOGURL_BEFORE_INIT:String = "http://wenku.baidu.com/tongji/view.html?type=flashload&subtype=beforeinit";
        public static const LOGURL_SCREENPAGEUP:String = "http://wenku.baidu.com/tongji/view.html?type=scrollup";
        public static const LOGURL_SCREENPAGEDOWN:String = "http://wenku.baidu.com/tongji/view.html?type=scrolldown";
        public static const LOGURL_CATALBTN_OPEN:String = "http://wenku.baidu.com/tongji/dir.html?type=open";
        public static const LOGURL_CATALBTN_CLOSE:String = "http://wenku.baidu.com/tongji/dir.html?type=close";
        public static const LOGURL_CATAL_EXIST:String = "http://wenku.baidu.com/tongji/dir.html?type=exist";
        public static const LOGURL_CATAL_JUMP:String = "http://wenku.baidu.com/tongji/dir.html?type=jump";
        public static const LOGURL_KEY_LEFT:String = "http://wenku.baidu.com/tongji/view.html?type=flashkeyleft";
        public static const LOGURL_KEY_RIGHT:String = "http://wenku.baidu.com/tongji/view.html?type=flashkeyright";
        public static const LOGURL_STORE_SLIDER:String = "http://wenku.baidu.com/tongji/shop.gif?type=reader_relate";
        public static const LOGURL_FULLSCREEN:String = "http://wenku.baidu.com/tongji/view.html?type=fullscreen";
        public static const LOGURL_ZOOMIN:String = "http://wenku.baidu.com/tongji/view.html?type=zoomin";
        public static const LOGURL_ZOOMOUT:String = "http://wenku.baidu.com/tongji/view.html?type=zoomout";
        public static const LOGURL_PAGEDOWN:String = "http://wenku.baidu.com/tongji/view.html?type=pagedown&pn=";
        public static const LOGURL_PAGEUP:String = "http://wenku.baidu.com/tongji/view.html?type=pageup&pn=";
        public static const LOGURL_SEARCH:String = "http://wenku.baidu.com/tongji/view.html?type=search&word=";
        public static const LOGURL_LOADSUCCESS_VIEW:String = "http://wenku.baidu.com/tongji/view.html?type=load&success=1";
        public static const LOGURL_BOOKMARKVIEW:String = "http://wenku.baidu.com/tongji/view.html?type=bookmark_view";
        public static const LOGURL_BOOKMARKCLICK:String = "http://wenku.baidu.com/tongji/view.html?type=bookmark_click";
        public static const LOGURL_LOADSUCCESS_API:String = "http://wenku.baidu.com/tongji/api.html?type=flash&subtype=view";
        public static const LOGURL_SHAREBUTTON:String = "http://wenku.baidu.com/tongji/api.html?type=flash&subtype=button";
        public static const LOGURL_SHAREICON:String = "http://wenku.baidu.com/tongji/api.html?type=flash&to=";
        public static const LOGURL_DOWNLOAD:String = "http://wenku.baidu.com/tongji/api.html?type=flash&subtype=download";
        public static const LOGURL_COPY:String = "http://wenku.baidu.com/tongji/api.html?type=flash&subtype=copy";
        public static const LOGURL_RELATIVE:String = "http://wenku.baidu.com/tongji/api.html?type=flash&subtype=relate";
        public static const LOGURL_SINGLEPAGE:String = "http://wenku.baidu.com/tongji/view.html?type=single";
        public static const LOGURL_DOUBLEPAGE:String = "http://wenku.baidu.com/tongji/view.html?type=double";
        public static const LOGURL_NEWMARK_BTN:String = "http://wenku.baidu.com/tongji/view.html?type=bookmark";
        public static const LOGURL_SERIES_EXIST:String = "http://wenku.baidu.com/tongji/series.html?type=exist";
        public static const LOGURL_SERIES_BTN:String = "http://wenku.baidu.com/tongji/series.html?type=open";
        public static const LOGURL_SERIES_JUMP:String = "http://wenku.baidu.com/tongji/series.html?type=jump";
        public static const LOGURL_FONTSIZEBIG:String = "http://wenku.baidu.com/tongji/view.html?type=big";
        public static const LOGURL_FONTSIZEMIDDLE:String = "http://wenku.baidu.com/tongji/view.html?type=middle";
        public static const LOGURL_FONTSIZESMALL:String = "http://wenku.baidu.com/tongji/view.html?type=small";
        public static const LOGURL_BGCOLOR:String = "http://wenku.baidu.com/tongji/view.html?type=bg";
        public static const LOGURL_AD_SUCCESS:String = "http://wenku.baidu.com/tongji/shop.gif?type=ad_success";
        public static const LOGURL_AD_FAILED:String = "http://wenku.baidu.com/tongji/shop.gif?type=ad_failed";
        public static const LOGURL_AD_TIMEOUT:String = "http://wenku.baidu.com/tongji/shop.gif?type=ad_timeout";
        public static const READER_TYPE_INTER_INT:int = 1;
        public static const READER_TYPE_EXTER_INT:int = 2;
        public static const READER_TYPE_ALL_INT:int = WenkuLog.READER_TYPE_INTER_INT | WenkuLog.READER_TYPE_EXTER_INT;

        public function WenkuLog(param1:IEventDispatcher = null)
        {
            super(param1);
            return;
        }// end function

        static function loaderEvent(event:Event = null) : void
        {
            var _loc_2:* = event.currentTarget as URLLoader;
            _loc_2.removeEventListener(Event.COMPLETE, loaderEvent);
            _loc_2.removeEventListener(ErrorEvent.ERROR, loaderEvent);
            _loc_2.removeEventListener(IOErrorEvent.IO_ERROR, loaderEvent);
            _loc_2.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, loaderEvent);
            return;
        }// end function

        public static function addLog(param1:String, param2:String = "", param3:int = 1) : void
        {
            var _loc_4:int = 0;
            var _loc_5:URLLoader = null;
            if (param1)
            {
                _loc_5 = new URLLoader();
                _loc_5.addEventListener(Event.COMPLETE, loaderEvent);
                _loc_5.addEventListener(ErrorEvent.ERROR, loaderEvent);
                _loc_5.addEventListener(IOErrorEvent.IO_ERROR, loaderEvent);
                _loc_5.addEventListener(SecurityErrorEvent.SECURITY_ERROR, loaderEvent);
                switch(InstanceManager.createSingletonInstance(LoaderInfoVO).readertype)
                {
                    case Config.READER_TYPE_EXTERNAL:
                    {
                        _loc_4 = WenkuLog.READER_TYPE_EXTER_INT;
                        break;
                    }
                    default:
                    {
                        _loc_4 = WenkuLog.READER_TYPE_INTER_INT;
                        break;
                        break;
                    }
                }
                if (!param2)
                {
                    param2 = Config.docType;
                }
                if (_loc_4 & param3)
                {
                    param1 = param1 + (param2 == Config.DOC_TYPE_DOC ? ("") : ("&doctype=txt"));
                    _loc_5.load(new URLRequest(param1 + "&t=" + new Date().time));
                }
            }
            return;
        }// end function

    }
}
